package com.service.system;

import com.common.ErrorCodeEnum;
import com.common.emums.DataStatus;
import com.common.exception.BusinessException;
import com.common.utils.StringUtils;
import com.core.springSecurity.common.SecurityUtils;

import com.dao.primary.system.SystemDeviceModelInfoMapper;
import com.model.domain.system.GetSystemDeviceModelInfoDO;
import com.model.domain.system.GetSystemDomainInfoDO;
import com.model.pojo.system.SystemDeviceModelInfo;
import com.model.pojo.system.SystemDomainInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;



/**
 * @Author: zql
 * @Description: 终端型号信息服务
 * @Data: 2023-11-21
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SystemDeviceModelInfoService {
    private final SystemDeviceModelInfoMapper systemDeviceModelInfoMapper;

    public List<SystemDeviceModelInfo> getPageList(GetSystemDeviceModelInfoDO getSystemDeviceModelInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getSystemDeviceModelInfoDO.getPage(),getSystemDeviceModelInfoDO.getPageSize(),getSystemDeviceModelInfoDO.getSortRow()+getSystemDeviceModelInfoDO.getSortOrder());
        return systemDeviceModelInfoMapper.selectList(getSystemDeviceModelInfoDO);
    }

    public List<SystemDeviceModelInfo> getAllList(GetSystemDeviceModelInfoDO getSystemDeviceModelInfoDO){
        PageHelper.clearPage();
        PageHelper.orderBy(getSystemDeviceModelInfoDO.getSortRow()+getSystemDeviceModelInfoDO.getSortOrder());
        return systemDeviceModelInfoMapper.selectList(getSystemDeviceModelInfoDO);
    }

    public int save(SystemDeviceModelInfo info){
        info.setCreateTime(new Date());
        return systemDeviceModelInfoMapper.insertSelective(info);
    }

    public int update(SystemDeviceModelInfo info){
        info.setLastModifiedTime(new Date());
        return systemDeviceModelInfoMapper.updateByPrimaryKeySelective(info);
    }

    public SystemDeviceModelInfo getById(Long id){
        return systemDeviceModelInfoMapper.selectByPrimaryKey(id);
    }

}
